package ll1;

import java.util.ArrayList;

public class Fset {

	private boolean firstset;
	private String name;
	private ArrayList<String> set;
	
	/**
	 * Data structure that is reserved for either First or Follow set
	 * @param firstSet - true is this is a first set, false if follow set
	 * @param theName - tells us what this set belongs to
	 */
	public Fset(boolean firstSet, String theName){
		firstset = firstSet;
		name = theName;
		set = new ArrayList<String>();
	}
	
	public void setSet(ArrayList<String> aSet){
		set = aSet;
	}
	
	public ArrayList<String> getSet(){
		return set;
	}
	
	public String getName(){
		return name;
	}
	
	public boolean isFirstSet(){
		return firstset;
	}
	
	/**
	 * Verbose add method
	 * @param element
	 * @return true if addition is successful - false if addition is unsuccessful OR there exist an element in list
	 */
	public boolean addInTo(String element){
		if(!set.contains(element)){
			set.add(element);
			return true;
		}
		return false;
	}
	
	public String toString(){
		String s;
		if(firstset){
			s = "First("+getName()+") : ";
		}
		else{
			s = "Follow("+getName()+") : ";
		}
		for(String element : set){
			s += element + " ";
		}
		
		return s;
	}
}
